package com.coffee.concurrent;

import com.google.common.eventbus.AsyncEventBus;
import com.google.common.eventbus.EventBus;

/**
 * 主要运用业务解耦
 * @author songkui
 * @since 2020-2-2 14:18
 **/
public class EventBusAsyncCenter {
    //分异步， 和同步
    private static EventBus eventBus = new AsyncEventBus("Guava-Event", ThreadPool.buildThreadPool(64, 512,  1024, 60, "Guava-Event"));

    private EventBusAsyncCenter() {

    }

    public static EventBus getInstance() {
        return eventBus;
    }

    public static void register(Object obj) {
        eventBus.register(obj);
    }

    public static void unregister(Object obj) {
        eventBus.unregister(obj);
    }

    public static void post(Object obj) {
        eventBus.post(obj);
    }

}
